package com.csiec.clock.fragment.login;

import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.csiec.clock.R;
import com.csiec.clock.databinding.LoginFragmentBinding;
import com.csiec.clock.databinding.RegisterFragmentBinding;
import com.csiec.clock.view.model.LoginViewModel;
import com.csiec.clock.view.model.RegisterViewModel;

public class RegisterFragment extends Fragment {

    private RegisterViewModel mViewModel;

    private RegisterFragmentBinding binding;

    private final String TAG = "RegisterFragment";

    public static RegisterFragment newInstance() {
        return new RegisterFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.register_fragment, container, false);
        return binding.getRoot();
    }


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewModel = new ViewModelProvider(this).get(RegisterViewModel.class);

        mViewModel.init(getActivity(), binding);
        binding.setRegisterViewModel(mViewModel);
        binding.setLifecycleOwner(this);


        binding.textGologin.setOnClickListener(v -> {
            NavController controller = Navigation.findNavController(v);
            controller.navigate(R.id.action_registerFragment_to_loginFragment);
        });
    }

}